﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Space
{
    public class AristotleShip : Ship
    {
        public override float Angle
        {
            get
            {
                return (float)Math.Atan2(Destination.Position.Z - Position.Z, Destination.Position.X - Position.X);
            }
        }

        public AristotleShip(Game game) : base(game)
        {
        }

        protected virtual void Arrived()
        {
        }

        public override void Update(float time)
        {
            Vector3 dest;
            //dest = Fleet.Position;
            dest = Destination.Position;

            float distance = (dest - Position).Length();
            //if (distanceSquare > Fleet.Size * 4 / 6)
            {
                if (distance > Speed + Destination.Radius)
                {
                    Vector3 dir = dest - Position;
                    dir.Normalize();
                    Position += dir * Speed;
                }
                else
                {
                    Arrived();
                }
            }
            base.Update(time);
        }
    }
}
